package dp;

import java.util.*;

/**
 * 小偷偷东西同类型题目
 */
public class hu1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] num = new int[n][3];
        int[] dp1 = new int[n];
        int[] dp2 = new int[n];
        int[] dp3 = new int[n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                num[i][j] = sc.nextInt();
            }
        }
        dp1[0] = num[0][0];
        dp2[0] = num[0][1];
        dp3[0] = num[0][2];
        int index = 0;
        for (int i = 1; i < n; i++) {
            int f = index;
            int min_value = Integer.MAX_VALUE;
            for (int j = 0 ; j < 3; j++) {
                if(j == f)
                    continue;
                if(num[i][j] < min_value){
                    index = j;
                    min_value = num[i][j];
                }
            }
            dp1[i] = dp1[i - 1] + min_value;
        }
        index = 1;
        for (int i = 1; i < n; i++) {
            int min_value = Integer.MAX_VALUE;
            int f = index;
            for (int j = 0 ; j < 3 ; j++) {
                if(j == f)
                    continue;
                if(num[i][j] < min_value){
                    index = j;
                    min_value = num[i][j];
                }
            }
            dp2[i] = dp2[i - 1] + min_value;
        }
        index = 2;
        for (int i = 1; i < n; i++) {
            int f = index;
            int min_value = Integer.MAX_VALUE;
            for (int j = 0 ; j < 3 ; j++) {
                if(j == f)
                    continue;
                if(num[i][j] < min_value){
                    index = j;
                    min_value = num[i][j];
                }
            }
            dp3[i] = dp3[i - 1] + min_value;
        }
        System.out.println(dp1[n - 1] + " " + dp2[n - 1] + " " + dp3[n - 1]);
        System.out.println(Math.min(dp1[n - 1], Math.min(dp2[n - 1], dp3[n - 1])));
    }
}


/*
2
5 6 7
1 3 4

3
15 8 17
12 20 9
11 7 5
 */